home *** CD-ROM | disk | FTP | other *** search
/ NASA Climatology Interdisciplinary Data Collection / NASA Climatology Interdisciplinary Data Collection - Disc 2.iso / cdrom.gui < prev    next >
Text File  |  1998-04-06  |  15KB  |  286 lines

  1. #  cdrom.gui - last revision: Jan 16, 1998
  2. #
  3. #  Sample widget script for the CIDC CDROM.
  4. #
  5. #  How to invoke this script:
  6. #
  7. #  At startup. Set the enviroment variable GAGUI with the
  8. #  name of the script file, e.g., 
  9. #
  10. #  % setenv GAGUI cdrom.gui
  11. #
  12. #  At the GrADS command line prompt. Simply type
  13. #
  14. #  ga> gui cdrom.gui
  15. #
  16. #  Of course, you must have a version of GrADS built with
  17. #  Athena Widgets support.
  18. #
  19. #  (c) 1997 Arlindo da Silva   (dasilva@gsfc.nasa.gov)
  20. #
  21. #              *** Copy freely but DO NOT sell ***
  22. #
  23. #  See also sample.gui.
  24. #.........................................................................
  25.  
  26. #  Most "exec" commands are supported
  27. #  ----------------------------------
  28.    set gxout shaded
  29.  
  30. # A "label" is an inactive widget which display some text, 
  31. # e.g., an informative  title. The first argument, "root"
  32. # in this case, is the name you give to the widget so that
  33. # you can refer to it later on
  34. # -------------------------------------------------------
  35.   MakeLabel(root,"CIDC CDROM II")
  36.  
  37. # This command creates a dropdown menu called " File... "
  38. # as usual, the first argument "file" is the name of the
  39. # widget
  40. # -------------------------------------------------------
  41.   MakeMenu ( file, "File" )
  42.  
  43. # Once you make a memu, you create its items. For the first item:
  44. # --------------------------------------------------------------
  45.       MakeMenuItem(open, file, "Open", Load, "open")
  46.  
  47. # The parameters this particular item are:
  48. #     open    the name of the item widget
  49. #     file    the menu the item belongs to (see MakeMenu above)
  50. #     "Open"  This is the text it displays on the screen
  51. #     Load    this is the callback name, i.e., the widget invokes
  52. #             this function when pressed. This particular callback
  53. #             pops up a "file finder" widget, and after the user
  54. #             clicks on a file name it executes the grads command
  55. #             "open" (see last argument) on this file. A list
  56. #             of the other available callbacks can be found in the
  57. #             end of this file.
  58. #     "open"  Argument to be passed to the callback. In this 
  59. #             particular case, it is the GrADS command to be
  60. #             executed on the file.
  61. #  The definition of the other items in this menu follows.
  62.       MakeMenuItem(fsel, file, "File Selection ", FileSel, NULL )
  63.       MakeMenuItem(browse, file, "View Text File", Browse, NULL)
  64.       MakeMenuItem(junk, file, "_______________", NULL, NULL )
  65.       MakeMenuItem(exec, file, "Exec", Load, "exec")
  66.       MakeMenuItem(run, file, "Run", Load, "run")
  67.       MakeMenuItem(gui, file, "GUI", Load, "gui")
  68.       MakeMenuItem(junk, file, "_______________", NULL, NULL )
  69.       MakeMenuItem(init, file, "Reinit", Cmd, "reinit")
  70.       MakeMenuItem(exit, file, "Exit", Cmd, "quit")
  71.  
  72. # A menu with assorted internal options
  73. # -------------------------------------
  74.   MakeMenu ( options, "Options" )
  75.       MakeMenuItem(map, options, "Continental Boundaries on/off",  CmdStr, "set mpdraw " )
  76.       MakeMenuItem(tit, options, "Draw Title", CmdStr, "draw title " )
  77.       MakeMenuItem(cbar, options, "Color Bar", Cmd, "run cbarn" )
  78.       MakeMenuItem(junk, options, "_______________", NULL, NULL )
  79.       MakeMenuItem(shade, options, "Shaded", Cmd, "set gxout shaded" )
  80.       MakeMenuItem(cont, options, "Contour", Cmd, "set gxout contour" )
  81.       MakeMenuItem(grfill, options, "Grid Fill", Cmd, "set gxout grfill" )
  82.       MakeMenuItem(grvals, options, "Grid Values", Cmd, "set gxout grid" )
  83.       MakeMenuItem(vec, options, "Vector", Cmd, "set gxout vector" )
  84.       MakeMenuItem(line, options, "Line Plot", Cmd, "set gxout line" )
  85.       MakeMenuItem(bar, options, "Bar Chart", Cmd, "set gxout bar" )
  86.  
  87. # Creates simple buttons. Buttons work pretty much like menu items
  88. # but they do not belong to any menu and are directly clickable.
  89. # ------------------------------------------------------------------
  90.   MakeButton( clear, "Clear", Cmd, "clear" )
  91.   MakeButton( quit, "Quit", Cmd, "quit" )
  92.   MakeButton( prompt, "ga>", CmdWin, NULL )
  93.  
  94. # A menu for defining GrADS dimensions. This is very crude right now.
  95. # I will be developing a specific callback with rubber bands
  96. # etc. for these functions. Stay tuned. 
  97. # ------------------------------------------------------------------
  98.   MakeMenu( dim, "Dim")
  99.       MakeMenuItem(lat, dim, "Latitude", CmdStr, "set lat " )
  100.       MakeMenuItem(lon, dim, "Longitude", CmdStr, "set lon " )
  101.       MakeMenuItem(time, dim, "Time", CmdStr, "set time " )
  102.       MakeMenuItem(junk, dim, "_________", NULL, NULL )
  103.       MakeMenuItem(x, dim, "x", CmdStr, "set x " )
  104.       MakeMenuItem(y, dim, "y", CmdStr, "set y " )
  105.       MakeMenuItem(z, dim, "z", CmdStr, "set z " )
  106.       MakeMenuItem(t, dim, "t", CmdStr, "set t " )
  107.  
  108. # Frequently used buttons (and toggle)
  109. # -----------------------------------
  110.   MakeButton( var, "Var", VarSel, NULL )
  111.   MakeToggle( hold, "Hold", FALSE, NULL, Toggle, "hold" )
  112.   MakeButton( prev, " << ", Display, "<<" )
  113.   MakeButton( displ, "Display", Display, "DISPLAY" )
  114.   MakeButton( next, " >> ", Display, ">>" )
  115.   MakeButton( rein, "Reinit", Cmd, "reinit")
  116.   MakeButton( fresh, "Fresh", Cmd, "  ")
  117.  
  118.  
  119. # CIDC CD-ROM I menu's
  120. # -------------
  121.   MakeMenu(old1, "Diagnostic 1)
  122.       MakeMenuItem(cfr, old1, "Cloud Fraction",  Open, "open data/assim_atmo_dyn/one_layer_diag/cldfrc/assim54a.cldfrc.1smdgg.ctl" )      
  123.       MakeMenuItem(evp, old1, "Surface Evaporation",  Open, "open data/assim_atmo_dyn/one_layer_diag/evap/assim54a.evap.1smdgg.ctl" )   
  124.       MakeMenuItem(olr, old1, "Outgoing Longwave Radiation",  Open, "open data/assim_atmo_dyn/one_layer_diag/olr/assim54a.olr.1smdgg.ctl" )   
  125.       MakeMenuItem(osr, old1, "Outgoing Shortwave Radiation",  Open, "open data/assim_atmo_dyn/one_layer_diag/osr/assim54a.osr.1smdgg.ctl" )    
  126.       MakeMenuItem(pbl, old1, "Planetary Boundary Layer Depth",  Open, "open data/assim_atmo_dyn/one_layer_diag/pbl/assim54a.pbl.1smdgg.ctl" )    
  127.       MakeMenuItem(prc, old1, "Total Precipitation",  Open, "open data/assim_atmo_dyn/one_layer_diag/preacc/assim54a.preacc.1smdgg.ctl" )   
  128.  
  129.   MakeMenu(old2, "Diagnostic 2")
  130.       MakeMenuItem(q2m, old2, "Specific Humidity at 2 Meters",  Open, "open data/assim_atmo_dyn/one_layer_diag/q2m/assim54a.q2m.1smdgg.ctl" )      
  131.       MakeMenuItem(qnt, old2, "Precipitable Water",  Open, "open data/assim_atmo_dyn/one_layer_diag/qint/assim54a.qint.1smdgg.ctl" )   
  132.       MakeMenuItem(lwg, old2, "Net Upward Longwave Radiation at Ground",  Open, "open data/assim_atmo_dyn/one_layer_diag/radlwg/assim54a.radlwg.1smdgg.ctl" )   
  133.       MakeMenuItem(swg, old2, "Net Downward Shortwave Radiation at Ground",  Open, "open data/assim_atmo_dyn/one_layer_diag/radswg/assim54a.radswg.1smdgg.ctl" )    
  134.       MakeMenuItem(swt, old2, "Incident Shortwave Radiation at TOA",  Open, "open data/assim_atmo_dyn/one_layer_diag/radswt/assim54a.radswt.1smdgg.ctl" )    
  135.       MakeMenuItem(t2m, old2, "Temperature at 2 Meters",  Open, "open data/assim_atmo_dyn/one_layer_diag/t2m/assim54a.t2m.1smdgg.ctl" )   
  136.  
  137.   MakeMenu(old3, "Diagnostic 3")
  138.       MakeMenuItem(tg,  old3, "Ground Temperature",  Open, "open data/assim_atmo_dyn/one_layer_diag/tg/assim54a.tg.1smdgg.ctl" )      
  139.       MakeMenuItem(ust, old3, "Surface Stress Velocity",  Open, "open data/assim_atmo_dyn/one_layer_diag/ustar/assim54a.ustar.1smdgg.ctl" )   
  140.       MakeMenuItem(vuq, old3, "Vertically Averaged uwnd * sphu",  Open, "open data/assim_atmo_dyn/one_layer_diag/vintuq/assim54a.vintuq.1smdgg.ctl" )   
  141.       MakeMenuItem(vvq, old3, "Vertically Averaged vwnd * sphu",  Open, "open data/assim_atmo_dyn/one_layer_diag/vintvq/assim54a.vintvq.1smdgg.ctl" )    
  142.       MakeMenuItem(wnd, old3, "Surface Wind Speed",  Open, "open data/assim_atmo_dyn/one_layer_diag/winds/assim54a.winds.1smdgg.ctl" )    
  143.       MakeMenuItem(z0,  old3, "Surface Roughness",  Open, "open data/assim_atmo_dyn/one_layer_diag/z0/assim54a.z0.1smdgg.ctl" )   
  144.  
  145.   MakeMenu(sprg, "Surf. Prognostic")
  146.       MakeMenuItem(lwi, sprg, "Land Water and Ice",  Open, "open data/assim_atmo_dyn/surf_prog/lwi/assim54a.lwi.1pmdgg.ctl" )    
  147.       MakeMenuItem(psp, sprg, "Surface Pressure Minus ptop",  Open, "open data/assim_atmo_dyn/surf_prog/psptop/assim54a.psptop.1pmdgg.ctl" )   
  148.       MakeMenuItem(slp, sprg, "Sea Level Pressure",  Open, "open data/assim_atmo_dyn/surf_prog/slp/assim54a.slp.1pmdgg.ctl" )   
  149.  
  150.   MakeMenu(uap, "Upper Air Prognostic")
  151.       MakeMenuItem(hgh, uap, "Geopotential Height",  Open, "open data/assim_atmo_dyn/upper_air_prog/hght/assim54a.hght.8pmdgg.ctl" )    
  152.       MakeMenuItem(sph, uap, "Specific Humidity",  Open, "open data/assim_atmo_dyn/upper_air_prog/sphu/assim54a.sphu.8pmdgg.ctl" )   
  153.       MakeMenuItem(tmp, uap, "Temperature",  Open, "open data/assim_atmo_dyn/upper_air_prog/tmpu/assim54a.tmpu.8pmdgg.ctl" )   
  154.       MakeMenuItem(uwn, uap, "Zonal Wind",  Open, "open data/assim_atmo_dyn/upper_air_prog/uwnd/assim54a.uwnd.8pmdgg.ctl" )   
  155.       MakeMenuItem(vwn, uap, "Meridional Wind",  Open, "open data/assim_atmo_dyn/upper_air_prog/vwnd/assim54a.vwnd.8pmdgg.ctl" )   
  156.  
  157. MakeButton(help, "Help", Browse, software/grads/help.txt)
  158.  
  159. # Once you define buttons and menus you may want to enforce their
  160. # relative position. The very first button is always placed at the
  161. # upper left corner.
  162. # ----------------------------------------------------------------
  163.  
  164.   # First row 
  165.   SetWidgetPos(file, PLACE_UNDER, root, NO_CARE, NULL)
  166.   SetWidgetPos(options, PLACE_UNDER, root, PLACE_RIGHT, file )
  167.   SetWidgetPos(dim, PLACE_UNDER, root, PLACE_RIGHT, options )
  168.   SetWidgetPos(prompt, PLACE_UNDER, root, PLACE_RIGHT, dim )
  169.   SetWidgetPos(help, PLACE_UNDER,   root, PLACE_RIGHT, prompt)
  170.  
  171.   # Second row
  172.   SetWidgetPos(old1, PLACE_UNDER, file, NO_CARE, NULL)
  173.   SetWidgetPos(old2, PLACE_UNDER, file, PLACE_RIGHT, old1)
  174.     
  175.   # Third row
  176.   SetWidgetPos(old3, PLACE_UNDER, old2, NO_CARE, NULL)
  177.   SetWidgetPos(sprg, PLACE_UNDER, old2, PLACE_RIGHT, old3)
  178.  
  179.   # Fourth row
  180.   SetWidgetPos(uap, PLACE_UNDER, old3, NO_CARE, NULL)
  181.  
  182.   # Fith row
  183.   SetWidgetPos(fresh, PLACE_UNDER, uap, NO_CARE, NULL )
  184.   SetWidgetPos(var, PLACE_UNDER, uap, PLACE_RIGHT, fresh )
  185.   SetWidgetPos(prev, PLACE_UNDER, uap, PLACE_RIGHT, var )
  186.   SetWidgetPos(displ, PLACE_UNDER, uap, PLACE_RIGHT, prev )
  187.   SetWidgetPos(next, PLACE_UNDER, uap, PLACE_RIGHT, displ )
  188.  
  189.   # Sixth row
  190.   SetWidgetPos(hold, PLACE_UNDER, fresh, NO_CARE, NULL )
  191.   SetWidgetPos(clear, PLACE_UNDER, fresh, PLACE_RIGHT, hold)
  192.   SetWidgetPos(rein, PLACE_UNDER, fresh, PLACE_RIGHT, clear )
  193.   SetWidgetPos(quit, PLACE_UNDER, fresh, PLACE_RIGHT, rein )
  194.  
  195. # In order to make your widgets appear on the screen you *must*
  196. # issue this command.
  197. # -------------------------------------------------------------
  198.   ShowDisplay()
  199.  
  200. # After your widgets appear on the screen, you can set the color 
  201. # of your widgets. The following colors are pre-defined:
  202. # white, back, red, green, blue, yellow.
  203. # --------------------------------------------------------------
  204.   GetNamedColor(gray,"grey")
  205.   GetNamedColor(Blue,"LightSkyBlue")
  206.   GetNamedColor(Green,"Green")
  207.   GetNamedColor(pink,"gold")         # pink is actually gold, get it?
  208.   AllFgColor(black)
  209.   AllBgColor(Blue)
  210.   SetBgColor(root,white)
  211.   SetFgColor(root,red)
  212.   SetBgColor(file,green)
  213.   SetBgColor(options,green)
  214.   SetBgColor(dim,green)
  215.   SetFgColor(prompt,yellow)
  216.   SetBgColor(prompt,red)
  217.   SetFgColor(help,yellow)
  218.   SetBgColor(help,red)
  219.   SetBgColor(prev,pink)
  220.   SetBgColor(displ,pink)
  221.   SetBgColor(next,pink)
  222.   SetBgColor(play,pink)
  223.   SetBgColor(fresh,pink)
  224.   SetBgColor(var,pink)
  225.   SetBgColor(hold,gray)
  226.   SetBgColor(clear,gray)
  227.   SetBgColor(reset,gray)
  228.   SetBgColor(rein,gray)
  229.   SetBgColor(quit,gray)
  230.  
  231. # And you must call this function at the end of your first GUI script.
  232. # This instructs the X Toolkit to enter an infinite loop, monitoring
  233. # keyboard and mouse events. Repeating: you *must* call MainLoop().
  234. # -------------------------------------------------------------------
  235.   MainLoop()
  236.  
  237. #........................................................................
  238. #
  239. # APPENDIX: Currently available callback functions
  240. #
  241. #     Browse    Opens a text file, such as a help file, on a separate
  242. #               window.
  243. #     Cmd       Executes a generic GrADS command
  244. #     CmdStr    Like Cmd, but the user is prompted for an additional
  245. #               string to be appended to the GrADS command.
  246. #     CmdWin    Invokes a window for GrADS command line interface.
  247. #               User can click on past commands from a list.
  248. #     CmdLine   Invokes the standard GrADS command line interface.
  249. #               When the command line is active the other widgets
  250. #               are not available (may be fixed in the future).
  251. # CloseWindow   Closes the current window (do not use for your primary
  252. #               window or you will get stuck).
  253. #     Display   A generic callback for displaying the current variable
  254. #               (or expression) set with VarSel. The options are:
  255. #                  <<    decrements time and executes display
  256. #                 PLAY   starts animation from current to last time
  257. #                DISPLAY just executes display
  258. #                  >>    increments time and  executes display
  259. #               If the "hold" toggle state is OFF (the default),
  260. #               the screen is cleared before displaying.
  261. #     Edit      Like browse, but the user can edit the file. This simple
  262. #               text editor is integrated with GrADS, providing a very
  263. #               elementary Integrated Development Enviroment (IDE) for
  264. #               GrADS scripts. In particular, the script being edited
  265. #               can be executed by clicking on a button (not
  266. #               implemented yet).
  267. #     FileSel   Pops up a scrollable list and asks the user to selected
  268. #               a file among the currently opened GrADS files (including
  269. #               SDFs). The selected file becomes the default.
  270. #     Load      Pops up a "file finder" widget, and after the user
  271. #               clicks on a file name it executes a GrADS command
  272. #               specified as the last argument. In case of "open" or 
  273. #               "sdfopen" the files becomes the default, and the
  274. #               user is asked to select a variable from this file.
  275. #     Open      Similar to Load, but the file name must be specified.
  276. #     Toggle    Turn internal options ON/OFF. The only internal
  277. #               option currently supported is "hold". This callback is
  278. #               usually used with MakeToggle(), see example above.
  279. #     VarSel    Pops up a scrollable list and asks the user to selected
  280. #               a variable from the default file. The user can also
  281. #               type a generic GrADS expression instead of selecting
  282. #               a single variable.
  283. #     NULL      Does not do anything, used for inactive buttons.
  284. #
  285. #........................................................................
  286.